<?php

namespace App\Enums;

/**
 * 单据状态
 */
enum DocStatus: int
{
    case WAIT           = 0; //待推
    case PUSH_SUCCESS   = 1; // 已推
    case PUSH_FAIl      = 2; // 推失败

    /**
     * name
     *
     * @return string
     */
    public function label(): string
    {
        return match ($this) {
            self::WAIT          => "待推送",
            self::PUSH_SUCCESS  => "推送成功",
            self::PUSH_FAIl     => "推送失败",
        };
    }

    /**
     * 根据值获取名称
     * @param $val
     * @return string
     */
    static function labelBy($val){
        $obj = self::tryFrom((int)$val);
        return $obj ? $obj->label() : '';
    }
}
